home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-04 / tool_inc.zip / ITOH.INC < prev    next >
Text File  |  1989-06-02  |  1KB  |  46 lines

  1.  
  2. (*
  3.  * Copyright 1987, 1989 Samuel H. Smith;  All rights reserved
  4.  *
  5.  * This is a component of the ProDoor System.
  6.  * Do not distribute modified versions without my permission.
  7.  * Do not remove or alter this notice or any other copyright notice.
  8.  * If you use this in your own program you must distribute source code.
  9.  * Do not use any of this in a commercial product.
  10.  *
  11.  *)
  12.  
  13. (******************************************************
  14.  *
  15.  * Procedure:  itoh
  16.  *
  17.  * Purpose:    converts an integer into a string of hex digits
  18.  *
  19.  * Example:    s := itoh(i);
  20.  *
  21.  *)
  22.  
  23. function itoh(i: longint): string8;   {integer to hex conversion}
  24. var
  25.    h:   string8;
  26.    w:   word;
  27.  
  28.    procedure digit(ix: integer; ii: word);
  29.    begin
  30.       ii := ii and 15;
  31.       if ii > 9 then 
  32.          ii := ii + 7;
  33.       h[ix] := chr(ii + ord('0'));
  34.    end;
  35.  
  36. begin
  37.    w := i and $FFFF;
  38.    h[0] := chr(4);
  39.    digit(1,w shr 12);
  40.    digit(2,w shr 8);
  41.    digit(3,w shr 4);
  42.    digit(4,w);
  43.    itoh := h;   
  44. end;
  45.  
  46.